<template>
  <div class="view">
    <!-- <h1>注册/登录</h1>
    <h2>手机号</h2> -->
    <input class="mobile" maxlength="11" placeholder-style="color: #777;font-weight: 300;" type="number" v-model="mobile" placeholder="请输入手机号"/>

    <button :class="isPass ? 'btn pass':'btn'" @click="next" :disabled="!isPass">下一步</button>
    <div class="tip">
      <p class="tip1">注册登录即表示阅读并同意</p>
      <p class="tip2" @click="safe">考拉出行<span>《法律条款及隐私政策》</span></p>
    </div>
  </div>
</template>

<script>

  export default {
    data() {
      return {
        mobile: '',
        isPass: false,
      }
    },

    watch: {
      mobile() {
        let phone = this.mobile
        if (/^1[3456789]\d{9}$/.test(phone)) {
          this.isPass = true
        } else {
          this.isPass = false
        }
      }
    },
    mounted () {
      wx.showToast({
        title: '请先登录',
        icon: 'none',
        duration: 2000
      });
    },
    methods: {
      safe(){
        wx.navigateTo({
          url: '/pages/rules/main'
        })
      },
      next() {
        wx.navigateTo({
          url: `../code/main?mobile=${this.mobile}`
        })
      }
    }
  }
</script>

<style scoped>
  .view {
    padding: 0;
  }
  .mobile {
    margin: 170px 0 120px;
    padding-left: 80px;
    width: 100%;
    height: 68px;
    line-height: 54px;
    border-bottom: 2px solid #ddd;
    color: #333;
    font-size: 40px;
  }
  .tip{
    margin: 300px auto 0;
    text-align: left;
    width: 430px;
  }
  .tip1{
    height:37px;
    font-size:28px;
    font-weight:400;
    color:#333333;
    line-height:37px;
  }
  .tip2{
    padding-top: 20px;
    font-size: 28px;
    line-height: 37px;
    color: #333333;
  }
  .tip2 span{
    color: #333333;
    text-decoration: underline;
  }
</style>
